<?php

namespace common\models;

use Yii;
use common\models\TagsModel;
use yii\db\ActiveRecord;
use common\models\base\BaseModel;

/**
 * This is the model class for table "relation_tags_art".
 *
 * @property integer $id
 * @property integer $art_id
 * @property integer $tags_id
 */
class RelationTagsArt extends BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'relation_tags_art';
    }
    
    public function getTag()
    {
        return $this->hasOne(TagsModel::className(), ['id' => 'tags_id']);
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['art_id', 'tags_id'], 'integer'],
            [['art_id', 'tags_id'], 'unique', 'targetAttribute' => ['art_id', 'tags_id'], 'message' => 'The combination of Art ID and Tags ID has already been taken.'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '编号',
            'art_id' => '文章编号',
            'tags_id' => '标签编号',
        ];
    }
}
